﻿namespace X2OPC.Core.DA
{
    using System;
    using System.Runtime.InteropServices;

    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("39c13a4f-011e-11d0-9675-0020afd8adb3"), ComVisible(true)]
    public interface IOPCBrowseServerAddressSpace
    {
        /// <summary>
        /// 查询组织名称 
        /// </summary>
        /// <param name="pNameSpaceType"></param>
        /// <returns></returns>
        [PreserveSig]
        int QueryOrganization([MarshalAs(UnmanagedType.U4)] out OPCNameSpaceType pNameSpaceType);

        /// <summary>
        /// 变更浏览的位置
        /// </summary>
        /// <param name="dwBrowseDirection"></param>
        /// <param name="szName"></param>
        /// <returns></returns>
        [PreserveSig]
        int ChangeBrowsePosition([In, MarshalAs(UnmanagedType.U4)] OPCBrowseDirection dwBrowseDirection, [In, MarshalAs(UnmanagedType.LPWStr)] string szName);

        /// <summary>
        /// 浏览 OPCServer 內所有定义的 OPCItem 
        /// </summary>
        /// <param name="dwBrowseFilterType"></param>
        /// <param name="szFilterCriteria"></param>
        /// <param name="vtDataTypeFilter"></param>
        /// <param name="dwAccessRightsFilter"></param>
        /// <param name="ppUnk"></param>
        /// <returns></returns>
        [PreserveSig]
        int BrowseOPCItemIDs([In, MarshalAs(UnmanagedType.U4)] OPCBrowseType dwBrowseFilterType, [In, MarshalAs(UnmanagedType.LPWStr)] string szFilterCriteria, [In, MarshalAs(UnmanagedType.U2)] short vtDataTypeFilter, [In, MarshalAs(UnmanagedType.U4)] OPCAccessRights dwAccessRightsFilter, [MarshalAs(UnmanagedType.IUnknown)] out object ppUnk);

        /// <summary>
        /// 取得 OPCItem 的 ID 
        /// </summary>
        /// <param name="szItemDataID"></param>
        /// <param name="szItemID"></param>
        /// <returns></returns>
        [PreserveSig]
        int GetItemID([In, MarshalAs(UnmanagedType.LPWStr)] string szItemDataID, [MarshalAs(UnmanagedType.LPWStr)] out string szItemID);

        /// <summary>
        /// 浏览存取OPCItem 的路径 
        /// </summary>
        /// <param name="szItemID"></param>
        /// <param name="ppUnk"></param>
        /// <returns></returns>
        [PreserveSig]
        int BrowseAccessPaths([In, MarshalAs(UnmanagedType.LPWStr)] string szItemID, [MarshalAs(UnmanagedType.IUnknown)] out object ppUnk);
    }
}
